Skip to content

STACKITLB-1837 | add ALB certificates to provider#1296

Open
david-mey-STACKIT wants to merge 17 commits intostackitcloud:mainfrom
david-mey-STACKIT:main
Open

STACKITLB-1837 | add ALB certificates to provider#1296
david-mey-STACKIT wants to merge 17 commits intostackitcloud:mainfrom
david-mey-STACKIT:main

Conversation

@david-mey-STACKIT
Copy link
Copy Markdown
Contributor

@david-mey-STACKIT david-mey-STACKIT commented Mar 13, 2026

Description

STACKITLB-1837

Add ALB TLS certificates provider (API: https://docs.api.stackit.cloud/documentation/certificates/version/v2)

Checklist

  • Issue was linked above
  • Code format was applied: make fmt
  • Examples were added / adjusted (see examples/ directory)
  • Docs are up-to-date: make generate-docs (will be checked by CI)
  • Unit tests got implemented or updated
  • Acceptance tests got implemented or updated (see e.g. here)
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

@david-mey-STACKIT david-mey-STACKIT force-pushed the main branch 4 times, most recently from 289b525 to f74a895 Compare March 16, 2026 14:10
@david-mey-STACKIT david-mey-STACKIT marked this pull request as ready for review March 16, 2026 14:15
@david-mey-STACKIT david-mey-STACKIT requested a review from a team as a code owner March 16, 2026 14:15
@github-actions
Copy link
Copy Markdown

This PR was marked as stale after 7 days of inactivity and will be closed after another 7 days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it.

@github-actions github-actions bot added the Stale PR is marked as stale due to inactivity. label Mar 28, 2026

subject {
common_name = "localhost"
organization = "Stackit Test"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
organization = "Stackit Test"
organization = "STACKIT Test"

func (r *certDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
descriptions := map[string]string{
"main": "Certificates resource schema.",
"id": "Terraform's internal resource ID. It is structured as `project_id`,`region`,`name`.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"id": "Terraform's internal resource ID. It is structured as `project_id`,`region`,`name`.",
"id": "Terraform's internal resource ID. It is structured as `project_id`,`region`,`cert_id`.",

The id should always contain the attributes, which a required to call the GET endpoint.

"id": "Terraform's internal resource ID. It is structured as `project_id`,`region`,`name`.",
"project_id": "STACKIT project ID to which the certificate is associated.",
"region": "The resource region (e.g. eu01). If not defined, the provider region is used.",
"cert-id": "The ID of the certificate.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep the map keys consistent in snake case, like the attributes itself

Suggested change
"cert-id": "The ID of the certificate.",
"cert_id": "The ID of the certificate.",

Computed: true,
},
"cert_id": schema.StringAttribute{
Description: descriptions["cert-id"],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Description: descriptions["cert-id"],
Description: descriptions["cert_id"],

Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
stringplanmodifier.UseStateForUnknown(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UseStateForUnknown is not needed here and can potentially cause some issues, so it should be removed

Suggested change
stringplanmodifier.UseStateForUnknown(),

ConfigVariables: testConfigVarsMax,
Config: testutil.CertProviderConfig() + resourceMaxConfig,
Check: resource.ComposeAggregateTestCheckFunc(
// Load balancer instance resource
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment doesn't fit

Comment on lines +150 to +151
resource.TestCheckResourceAttrSet("stackit_alb_certificate.certificate", "public_key"),
resource.TestCheckResourceAttrSet("stackit_alb_certificate.certificate", "private_key"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can do here the same check mentioned above


"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/stackitcloud/stackit-sdk-go/core/config"
certSdk "github.com/stackitcloud/stackit-sdk-go/services/certificates"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
certSdk "github.com/stackitcloud/stackit-sdk-go/services/certificates"
certSdk "github.com/stackitcloud/stackit-sdk-go/services/certificates/v2api"

}
return fmt.Sprintf(`
provider "stackit" {
cart_custom_endpoint = "%s"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cart_custom_endpoint = "%s"
alb_certificates_custom_endpoint = "%s"

Comment on lines +19 to +21
if providerData.ALBCustomEndpoint != "" {
apiClientConfigOptions = append(apiClientConfigOptions, config.WithEndpoint(providerData.ALBCustomEndpoint))
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if providerData.ALBCustomEndpoint != "" {
apiClientConfigOptions = append(apiClientConfigOptions, config.WithEndpoint(providerData.ALBCustomEndpoint))
}
if providerData.ALBCertificatesCustomEndpoint != "" {
apiClientConfigOptions = append(apiClientConfigOptions, config.WithEndpoint(providerData.ALBCertificatesCustomEndpoint))
}

@marceljk marceljk removed the Stale PR is marked as stale due to inactivity. label Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants